package kk.service;

import kk.domain.Role;
import kk.domain.UserInfo;
import org.springframework.security.core.userdetails.User;
import org.springframework.security.core.userdetails.UserDetailsService;

import java.util.List;

public interface UserService extends UserDetailsService {

    /**
     * 查询所有用户
     * @return
     */
    public List<UserInfo> findAll(Integer pageNum,Integer pageSize) throws Exception;

    /**
     * 添加用户
     * @param userInfo
     * @throws Exception
     */
    public void save(UserInfo userInfo)throws Exception;

    /**
     * 根据id查询用户信息
     * @param id
     * @return
     * @throws Exception
     */
    public UserInfo findById(Integer id)throws Exception;

    /**
     * 根据用户的id查询用户所没有的角色
     * @param uid
     * @return
     */
    public List<Role> findOtherRoles(Integer uid);

    /**
     * 给用户添加角色
     * @param userId
     * @param ids
     */
    public void addRoleToUser(Integer userId,int[] ids) throws Exception;

    /**
     * 根据id删除用户
     * @param id
     * @throws Exception
     */
    public void deleteById(Integer id) throws Exception;

    /**
     * 根据用户id查询出用户已经拥有的角色
     * @param userId
     * @return
     * @throws Exception
     */
    public List<Role> findExistRoles(Integer userId) throws Exception;

    /**
     * 给用户删除角色
     * @param userId
     * @param ids
     * @throws Exception
     */
    public void deleteRoleFromUser(Integer userId,int[] ids) throws Exception;

}
